#include <iostream>
using namespace std;


class Base {
public:
	virtual void func1() { cout << "Base::func1" << endl; }
	virtual void func2() { cout << "Base::func2" << endl; }
private:
	int a=0;
};
class Derive :public Base {
public:
	virtual void func1() { cout << "Derive::func1" << endl; }
	virtual void func3() { cout << "Derive::func3" << endl; }
	virtual void func4() { cout << "Derive::func4" << endl; }
	void func5() { cout << "Derive::func4" << endl; }

private:
	int b=0;
};

class X :public Derive {	
public:
	virtual void func3() { cout << "X::func3" << endl; }

private:
	int c = 0;
};


typedef void (*VFUNC)();
void PrintVFT(VFUNC a[])
{
	for (size_t i = 0; a[i] != 0; i++)
	{
		printf("[%d]: %p", i, a[i]);
		VFUNC f = a[i];
		f();

	}
	printf("\n");
}

int main()
{
	Base b;
	Derive d;
	X x;

	PrintVFT((VFUNC*)(*((int*)&b)));
	PrintVFT((VFUNC*)(*((int*)&d)));
	PrintVFT((VFUNC*)(*((int*)&x)));

	return 0;
}
